﻿var pageSize=10;
var currentIndex=1;
//评论弹出框
var findhelp=document.getElementById("findhelp"); //寻求帮助按钮
var formone=document.getElementsByClassName("formone")[0]; //寻求帮助弹出框
var formtwo=document.getElementsByClassName("formtwo")[0];

var modalbg=document.getElementsByClassName("modal_bg2")[0];
var modal=document.getElementsByClassName("action_menu_container2")[0];
var cancel=document.getElementsByClassName("cancel");
var timer;

for(var i=0;i<cancel.length;i++){
    cancel[i].onclick=function(){
        if(modalbg.style.display=="block"&&modal.style.display=="block"){
            modalbg.className+=' animate_out';
            modal.className+=' animate_out';
        }
        timer=setTimeout(changeclass,100);
    };
}
function changeclass(){
    modalbg.className='modal_bg modal_bg2';
    modal.className='action_menu_container action_menu_container2';
    clearTimeout();
    timer=null;
    changedisplay();
};
function changedisplay(){
    modalbg.style.display="none";
    modal.style.display="none";
};
//        弹出收藏转发
var paybtn1=document.getElementById("paybtn1");
var modalbg1=document.getElementsByClassName("modal_bg1")[0];
var modal1=document.getElementsByClassName("action_menu_container1")[0];
var cancel1=document.getElementsByClassName("cancel1")[0];
var timer1;

paybtn1.onclick=function(){
    modalbg1.style.display="block";
    modal1.style.display="block";
};

cancel1.onclick=function(){
    if(modalbg1.style.display=="block"&&modal1.style.display=="block"){
        modalbg1.className+=' animate_out';
        modal1.className+=' animate_out';
    }
    timer1=setTimeout(changeclass1,100);
};

function changeclass1(){
    modalbg1.className='modal_bg modal_bg1';
    modal1.className='action_menu_container action_menu_container1';
    clearTimeout();
    timer=null;
    changedisplay1();
};
function changedisplay1(){
    modalbg1.style.display="none";
    modal1.style.display="none";
};
//相关经验金钱判断能否进入
function moneytest(e){
    //判断能不能去看详情页
    var euserid= e.dataset.euser;
    var thiseid= e.dataset.eid;
    var score=e.dataset.score;
    $.ajax({
        type:"post",
        datatype:"json",
        url:textexpurl,
        data:{"quserId":euserid,"contentId":thiseid,"userId":id,"score":score},
        success:function(d){
            console.log(d);
            if(d.Message=="自己的经验"||d.Message=="已付费"){
                $.cookie("paynum",thiseid);
                location.href='shareexppage.html?eid='+thiseid;
            }else if(d.Message=="未付费"){
                //高额经验弹框
                if(e.dataset.isheight==="0"||e.dataset.isheight==="null"){
                    $.cookie("paynum",thiseid);
                    location.href='shareexppage.html?eid='+thiseid;
                }else if(e.dataset.isheight==="1"){
                    $("#heightexpscore").html(parseFloat(score)/100);
                    $("#heightexpdiv").toggle(200);
                };
                $("#heightexpok").click(function(){
                    $("#heightexpdiv").toggle(200);
                    $.cookie("paynum",thiseid);
                    location.href='shareexppage.html?eid='+thiseid;
                });
            }else{
                $.cookie("paynum","NO");
                $("#waitplace").css("display","block");
                $("body").css("overflow","hidden");
            }
        }
    });
}
$("#heightexpno").click(function(){
    $("#heightexpdiv").toggle(200);
});
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var upers;//点赞的人 用于点赞判断
var countnum=document.getElementById("countnum");
var goodbtn=document.getElementById("goodbtn");
var isclickgood=0;
//查看所有品论页面
function comment(e){
    var sendeid="";
    if(e.dataset.eid){
        sendeid="eid="+e.dataset.eid;
    };
    location.href="comment.html?aid="+e.id+"&"+sendeid;
};
//获取经验页地址及拼接参数
var locathref=location.href;
var eid=location.href.match(/eid=[0-9]+/)[0];
console.log("当前经验拼接数据："+eid);
//查看者信息用于假数据
var mynick="",myimg="",mysig="";
var money=0;
var euserid="";//发布者id
//点击输入框动画参数
var allheihgt=230;
var stepleng=allheihgt/10;
//--------------------------------------
var starhash={
    "1":"写的不错",
    "2":"受教了",
    "3":"豁然开朗",
    "4":"经验很有用",
    "5":"受益匪浅",
    "6":"感谢分享",
    "7":"普普通通",
    "8":"被坑了",
    "9":"写的一般",
    "10":"废话太多",
    "11":"然而并没有用",
    "12":"白花钱了"
}
//获取回答
function getanswer(){
    console.log(eid);
    if(/^\d+$/.test(eid)){

    }else{
        eid=eid.split("=")[1];
    }
    //获得回答
    $.ajax({
        type:"get",
        url:getexpcomurl+eid+"&pageSize="+pageSize+"&currentIndex="+currentIndex+"&userId="+id,
        datatype:"json",
        success:function(data){
            console.log(data);
            if(data.Data){
                dd=data.Data.commentList;
            }
            if(dd&&dd.length>0){
                //第一次加载展示评价标签
                if(currentIndex===1){
                    $("#noticeevalu").css("display","block");
                    if(data.Data.exStarList&&data.Data.exStarList.length>0){
                        var expstarcode="";
                        //console.log(starhash[data.Data.exStarList[a].labelId]);
                        for(var a=0;a<data.Data.exStarList.length;a++){
                            expstarcode+="<div class='item'>"+starhash[data.Data.exStarList[a].labelId]+"("+data.Data.exStarList[a].count+")</div>"
                        }
                        $("#noticeevalu .noticebox").append(expstarcode);
                    }
                }
                if(dd.length<pageSize){
                    $("#addmoreanswerbtn").css("display","none");
                }else{
                    $("#addmoreanswerbtn").css("display","block");
                }
                $("#QuestionMain").css("display","block");
                for(var l=0;l<dd.length;l++){
                    //var answerimgs=""; //保存图片代码段
                    var htmlword="";//保存图片代码段
                    var tim="";//保存时间
                    //var sig="";
                    //判断是否有图片
                    //if(dd[l].imgList.length>0){
                    //    for(var li=0;li<dd[l].imgList.length;li++){
                    //        htmlword+="<div class='imgbox'><img src='http://42.62.66.198:8003/"+dd[l].imgList[li].imgPath+"'/></div>";
                    //    }
                    //    if(htmlword){
                    //        answerimgs="<div class='qtext_para qimgs answerimgs'>"+htmlword+"</div>";
                    //    }
                    //};
                    //if(dd[l].user.sign){
                    //    sig=" · "+dd[l].user.sign;
                    //}

                    //获得时间
                    if(dd[l].cTime){
                        tim=getDateDiff(getDateTimeStamp(dd[l].cTime));
                    };
                    var headerimg="<img src='../img/af8.png'> ";
                    if(dd[l].userAva){
                        headerimg="<img src='http://42.62.66.198:8003/"+dd[l].userAva+"'> ";
                    }
                    var pinglun="<a class='commentbtn' onclick='comment(this)' data-eid='"+eid+"' id='c"+dd[l].answerId+"'>评论</a>";
                    var newcontent=codetoface(dd[l].content);//回复文字中插入表情图片
                    if(tim){}else{tim="刚刚"};
                    //二级评论
                    var secondword="";
                    if(dd[l].commentList&&dd[l].commentList.length>0){
                        for(var r1=0;r1<dd[l].commentList.length;r1++){
                            var replyto="";
                            if(dd[l].commentList[r1].replyToUserNick){
                                replyto=" 回复 "+dd[l].commentList[r1].replyToUserNick;
                            }
                            var secondfaceword=codetoface(dd[l].commentList[r1].content);
                            secondword+="<div class='secondword' id='second"+dd[l].commentList[r1].commentId+"'><span class='username'>"+dd[l].commentList[r1].userNick+replyto+"：</span><span class='userword commentbtn' data-replyname='"+dd[l].commentList[r1].userNick+"' data-reply='"+dd[l].commentList[r1].commentId+"' data-eid='"+eid+"' id='c"+dd[l].answerId+"' onclick='comment(this)'>"+secondfaceword+"</span></div>";
                        }
                        secondword="<div class='secondchat'><div class='secondlogo'></div><div class='secondwordplace'>"+secondword+"<div></div>";
                    }
                    $("#QuestionMain").append("<div class='othersanswer'> <div class='AnswerPagedList PagedList'> <div class='Answer on_question_page'> <div class='user-pic'> <a href='otherpeoplepage.html?otherid="+dd[l].userId+"'> "+headerimg+" </a> </div> <div class='comment'> <div class='username'> <span> "+dd[l].userNick+" </span> <span class='rt'>"+tim+"</span> </div> <span class='star star0'><i style='width:"+parseFloat(dd[l].experienceStar)*20+"%'></i></span><div class='comment-entry'> "+newcontent+"</div><div class='comment-btnplace'>"+pinglun+"</div> "+secondword+"</div> </div> </div> </div> </div> </div>");
                }
                htmlword="";
                answerimgs="";
                tim="";
            }
            else{
                $("#QuestionMain").css("display","none");
                $("#addmoreanswerbtn").css("display","none");
            }
        }
    });
};
//点击加载更多回答-----------------------------------------------
$("#addmoreanswerbtn").click(function(){
    currentIndex++;
    getanswer();
});

$().ready(function(){
    var reg=/(eid=)([0-9]*)/;
    var eid=urlfrom.match(reg).splice("=")[2];
    //获取查看者信息用于假数据
    //$.ajax({
    //    type: "post",
    //    //提交的网址
    //    url: "http://42.62.66.198:9001/api/puluuser/getuser",
    //    //提交的数据
    //    data: { "userId": id },
    //    //返回数据的格式
    //    datatype: "json",//"xml", "html", "script", "json", "jsonp", "text"
    //    success:function(mydata){
    //        mynick=mydata.Data.nick;
    //        if(mydata.Data.userAva){
    //            myimg=imgurl+mydata.Data.userAva;
    //        }else{
    //            myimg="../img/af8.png";
    //        }
    //        //if(mydata.Data.jobs&&mydata.Data.jobs.length>0){
    //        //    mysig=mydata.Data.jobs[0].typename;
    //        //}
    //        if(mydata.Data.sign){
    //            mysig=" · "+mydata.Data.sign;
    //        }
    //    }
    //});
    //获得经验
    $.ajax({
        type:"get",
        url:getdetialurl+eid,
        //data:{"questionId":eid},
        datatype: "json",
        success:function(data){
            console.log("经验数据：",data);
            $("title").html(data.Data.title);
            exptitle=data.Data.title;
            console.log(data.Data);
            euserid=data.Data.userId;
            //if(data.Data.user.userId==id){isfrom=0} 是否为转发别人的转发

            //var label=data.Data.Pulu_Question.hobbytypenames+","+data.Data.Pulu_Question.jobtypenames;
            //var reg1=/([A-Za-z0-9\u4E00-\u9FA5]*)/;
            //var word=label.match(reg1);
            ////console.log(word);
            //for(var i=0;i<word.length;i++){
            //    word[i].index=i;
            //    if(word[i]!=="null"){
            //        console.log("判断唯空："+i+":"+word[i]);//.TopicListItems2
            //        $(".QuestionTopics.has_topics").append("<a class='TopicNameLink HoverMenu topic_name'>"+word[i]+"</a>")
            //    }else if(!word[i]){
            //        console.log("空");
            //    }
            //}
            //upers=data.Data.userList;
            if(data.Data.keyWords&&data.Data.keyWords.length>0){
                var keywords=data.Data.keyWords;
                if(keywords.match(/，/)){
                    if(keywords.match(/，/)){
                        keywords=keywords.replace(/，/g,",");
                    }
                    keywords=keywords.split(",");
                    console.log(keywords);
                    for(var k=0;k<keywords.length;k++){
                        $(".QuestionTopics.has_topics").append("<span>"+keywords[k]+"</span>")
                    }
                }else{
                    keywords=keywords.split(",");
                    console.log(keywords);
                    for(var k=0;k<keywords.length;k++){
                        $(".QuestionTopics.has_topics").append("<span>"+keywords[k]+"</span>")
                    }
                }
            }
            if(data.Data.location&&data.Data.location.length>0){
                $(".locationplace").css("display","block");
                $(".locationplace span").html(data.Data.location);
            }

            $(".allgetmoney").html("总收入"+parseFloat(data.Data.totalIncome)/100+"元");
            //$(".gettitle").html(data.Data.Pulu_Question.title);
            var facecode=codetoface(data.Data.content);
            $(".getcontent").html(facecode);
            //$("#countnum").html(data.Data.userList.length);
            $(".senderinfo .lf span").html(parseFloat(data.Data.score)/100);//经验有多少钱
            var money=parseFloat(data.Data.score);
            //评星
            if(data.Data.starScore){
                $("#detailstar i").css("width",parseInt(data.Data.starScore)*20+"%");
            }
            //if(data.Data.Pulu_Question.ishidename==1&&id!=data.Data.user.userId){
            if(data.Data.isHideName==1){
                $(".senderinfo .rt #sendernick").append("<a>匿名</a>");
            }else{
                $(".senderinfo .rt #sendernick").append("<a href='otherpeoplepage.html?otherid="+data.Data.userId+"'>"+data.Data.userNick+"</a>");
            }
            var sendtime="";
            if(data.Data.cTime){
                sendtime=getDateDiff(getDateTimeStamp(data.Data.cTime));
            };
            function showtime(){
                if(sendtime&&sendtime.length>0){
                    $(".senderinfo .rt #sendertime").html(sendtime);
                }else{
                    $(".senderinfo .rt #sendertime").html("刚刚");
                }
            };
            showtime();
            $("#sharetitleword div").html(data.Data.title);
            if(data.Data.ImgList&&data.Data.ImgList.length>0){
                expimg="http://42.62.66.198:8003/"+data.Data.ImgList[0].imgPath;
                for(var r=0;r<data.Data.ImgList.length;r++){
                    $("#qimgsplace").append("<div class='imgbox'><img src='http://42.62.66.198:8003/"+data.Data.ImgList[r].imgPath+"'/></div>");
                }
                var showimgwidth=$(".qimgs .imgbox").width();
                $(".qimgs .imgbox").height("auto");
            }
            //赞同
            //if(upers.length>0){
            //    console.log(upers.length);
            //    for(var u=0;u<upers.length;u++){
            //        if((upers[u])&&(upers[u].userId==id)){
            //            console.log("已经点击了");
            //            goodbtn.style.color="#6d6d6d";
            //            countnum.style.color="#6d6d6d";
            //            isclickgood=1;
            //        }else{
            //            goodbtn.onclick=function(){
            //                if(isclickgood==0){
            //                    isclickgood=1;
            //                    goodbtn.style.color="#6d6d6d";
            //                    countnum.style.color="#6d6d6d";
            //                    countnum.innerHTML=parseFloat(countnum.innerHTML)+1;
            //                    var num=countnum.innerHTML;
            //                    console.log("点击完成1");
            //                    $.ajax({
            //                        type:"post",
            //                        dataType: "json",
            //                        url:"http://42.62.66.198:9001/api/PuluUpdown/AddPulu_updown",
            //                        data:{"contentid":eid,"userid":id,"isup":1},
            //                        success:function(data){
            //                            console.log("点赞提交："+data);
            //                            console.log(data);
            //                        }
            //                    })
            //                }
            //            }
            //        }
            //    }
            //}
            //else{
            //    goodbtn.onclick=function(){
            //        if(isclickgood==0){
            //            isclickgood=1;
            //            goodbtn.style.color="#6d6d6d";
            //            countnum.style.color="#6d6d6d";
            //            countnum.innerHTML=parseFloat(countnum.innerHTML)+1;
            //            var num=countnum.innerHTML;
            //            console.log("点击完成");
            //            $.ajax({
            //                type:"post",
            //                dataType: "json",
            //                url:"http://42.62.66.198:9001/api/PuluUpdown/AddPulu_updown",
            //                data:{"contentid":eid,"userid":id,"isup":1},
            //                success:function(data){
            //                    console.log("点赞提交："+data);
            //                    console.log(data);
            //                }
            //            })
            //        }
            //    }
            //}
            //是否为付费经验有金钱 并进行提醒
            //console.log("paynum:"+ $.cookie("paynum"));
            //if(data.Data.Pulu_Question.score>0&&euserid!=id){
            //    money=data.Data.Pulu_Question.score;
            //    $(".senderinfo .lf").css("display","block");
            //    //有没有付过钱
            //    if($.cookie("paynum")!=eid){
            //        //moneynotein();
            //    };
            $("#modalscore").html(data.Data.score);
            //    $("#moneyinput").val(parseFloat(data.Data.Pulu_Question.score));
            //    $("#showmoney span").html(data.Data.Pulu_Question.score);
            //}else{
            //    $(".senderinfo .lf").css("display","none");
            //    $("#tishiwords").remove();
            //    $("#paybtn").html("打赏");
            //    $("#showmoney").html("打赏金额");
            //};
            //进行付费操作 是不是自己的经验
            if(euserid!=id){
                //判断有没有付完款
                $.ajax({
                    type:"post",
                    datatype:"json",
                    url:textexpurl,
                    data:{"quserId":euserid,"contentId":eid,"userId":id,"score":parseFloat(money)},
                    success:function(d){
                        console.log(d);
                        if(d.Message=="未付费"){
                            $.ajax({
                                type:"post",
                                datatype:"json",
                                url:payexpurl,
                                data:{"quserId":euserid,"contentId":eid,"userId":id,"score":parseFloat(money)},
                                success:function(d){
                                    console.log(d);
                                    if(d.Code==="TRUE"){
                                        //moneynotein();
                                    };
                                    //出现弹框
                                    function moneynotein(){
                                        var topp=parseFloat(document.getElementById("moneynote").style.top);
                                        if(parseFloat(document.getElementById("moneynote").style.top)>=0){
                                            clearTimeout();
                                            stoptime();
                                        }else if(parseFloat(document.getElementById("moneynote").style.top)<0){
                                            setTimeout(function(){
                                                document.getElementById("moneynote").style.top=parseFloat(document.getElementById("moneynote").style.top)+5+"px";
                                                moneynotein();
                                            },40);
                                        }
                                    }
                                    function stoptime(){
                                        setTimeout(moneynoteout,2000);
                                    }
                                    //消失弹框
                                    function moneynoteout(){
                                        var topp=parseFloat(document.getElementById("moneynote").style.top);
                                        if(parseFloat(document.getElementById("moneynote").style.top)<-100){
                                            clearTimeout();
                                        }else if(parseFloat(document.getElementById("moneynote").style.top)>-100){
                                            setTimeout(function(){
                                                document.getElementById("moneynote").style.top=parseFloat(document.getElementById("moneynote").style.top)-5+"px";
                                                moneynoteout();
                                            },40);
                                        }
                                    }
                                }
                            });
                        }
                    }
                });
            }
            else{
                if(data.Data.Pulu_Question.isexphigh===1){
                    $("#changeexp").css("display","none");
                }else{
                    $("#changeexp").css("display","block");
                }
            }
        }
    });
    //编辑修改经验跳转
    $("#changeexp").click(function(){
        if(euserid===id){
            location.href="changeexp.html?eid="+eid;
        }
    });
    //获得回答
    $.ajax({
        type:"get",
        url:"http://42.62.66.198:9001/api/PuluAnswer/GetAnswerByQuestionId?questionId="+eid+"&pageSize="+pageSize+"&currentIndex="+currentIndex+"&userId="+id,
        datatype:"json",
        success:function(data){
            console.log(data);
            var dd=data.Data.PuluanswerExt;
            if(dd&&dd.length>0){
                $("#QuestionMain").css("display","block");
                for(var l=0;l<dd.length;l++){
                    var answerimgs=""; //保存图片代码段
                    var htmlword="";//保存图片代码段
                    var tim="";//保存时间
                    var sig="";
                    //判断是否有图片
                    if(dd[l].imgs.length>0){
                        for(var li=0;li<dd[l].imgs.length;li++){
                            htmlword+="<div class='imgbox'><img src='http://42.62.66.198:8003/"+dd[l].imgs[li].imgPath+"'/></div>";
                        }
                        if(htmlword){
                            answerimgs="<div class='qtext_para qimgs answerimgs'>"+htmlword+"</div>";
                        }
                    };
                    if(dd[l].user.sign){
                        sig=" · "+dd[l].user.sign;
                    }
                    //获得时间
                    //var regtime=/([0-9\-])*/;
                    //tim=dd[l].answer.ctime.match(regtime)[0];
                    if(dd[l].answer.ctime){
                        tim=getDateDiff(getDateTimeStamp(dd[l].answer.ctime));
                    };
                    var newcontentcode=codetoface(dd[l].answer.content);//回复文字中插入表情图片
                    function showtime(){
                        if(tim&&tim.length>0){
                            var pinglun="<a class='commentbtn' onclick='comment(this)' data-eid='"+eid+"' id='c"+dd[l].answer.id+"'>评论</a>";
                            var headerimg="<img class='profile_photo_img' src='../img/af8.png'> ";
                            if(dd[l].user.userAva){
                                headerimg="<img class='profile_photo_img' src='http://42.62.66.198:8003/"+dd[l].user.userAva+"'> ";
                            }
                            $("#QuestionMain").append("<div class='othersanswer'> <div class='AnswerPagedList PagedList'> <div class='Answer on_question_page'> <div class='answer_text'> <div class='ContentHeader'> <div class='photo_info_layout size_small'> <div class='photo_wrapper'> <div class='photo'> <a href='otherpeoplepage.html?otherid="+dd[l].user.userId+"'>"+headerimg+"</a></div> </div> <div class='info_wrapper'> <span class='feed_item_answer_user'> <span class='user'>"+dd[l].user.nick+"</span><span class='sign'>"+sig+"</span> </span> <div class='ContentFooter'>"+tim+"</div> </div> </div> </div> <div class='answer_content'> <span class='rendered_qtext'> <p class='qtext_para'>"+newcontentcode+"</p> "+answerimgs+"</span> </div> </div><div class='ActionBar'> <div class='action_bar_inner'><div class='action_item'>"+pinglun+"</div></div> </div>     </div> </div> </div>");
                        }else{
                            showtime();
                        }
                    };
                    showtime();
                }
                htmlword="";
                answerimgs="";
                tim="";
            }else{
                $("#QuestionMain").css("display","none");
            }
        }
    });
    //获得相关经验
    function relevantnews(currentIndex){
        $.ajax({
            type:"get",
            datatype:"json",
            url:relevantexpurl+id+"&currentIndex="+currentIndex+"&pageSize=5&questionId="+eid+"&qtype=3",
            success:function(d){
                //console.log("相关经验");
                //console.log(d);
                if(d.Data&&d.Data.length>0){
                    for(var i=0;i<d.Data.length;i++){
                        $("#Relevantexp").append("<li class='Cell'><a class='tc_inner' style='overflow:hidden;' onclick='moneytest(this)' data-isheight='"+d.Data[i].isHigh+"' data-score="+d.Data[i].score+" data-eid="+d.Data[i].id+" data-euser="+d.Data[i].questionUserId+"><span class='tc_text'>"+d.Data[i].title+"</span><span class='rt' style='padding-left:16px;padding-right:20px;'>"+(parseFloat(d.Data[i].score)/100)+"</span></a><div class='tc_discl'></div><div class='tc_stroke'></div></li>")
                    }
                    if(d.Data.length<5){
                        $("#moreexp").css("display","none");
                    }else{
                        $("#moreexp").css("display","block");
                    }
                }else{
                    $("#Relevantexp").append("<li class='Cell' style='background:#fff'><a class='tc_inner' style='text-align: center'><span class='tc_text' style='font-size:15px;color:#999;'>无相关经验</span></a></li>");
                    $("#moreexp").css("display","none");
                }
            }
        });
    }
    relevantnews(1);//前五条相关经验

    //更多相关经验
    $("#moreexp").click(function(){
        $.ajax({
            type:"get",
            datatype:"json",
            url:relevantexpurl+id+"&currentIndex=2&pageSize=5&questionId="+eid+"&qtype=3",
            success:function(d){
                console.log("相关经验");
                console.log(d);
                if(d.Data&&d.Data.length>0){
                    for(var i=0;i<d.Data.length;i++){
                        $("#Relevantexp").append("<li class='Cell'><a class='tc_inner' style='overflow:hidden;' onclick='moneytest(this)' data-score="+d.Data[i].score+" data-eid="+d.Data[i].id+" data-euser="+d.Data[i].questionUserId+"><span class='tc_text'>"+d.Data[i].title+"</span><span class='rt' style='padding-left:16px;padding-right:20px;'>"+(parseFloat(d.Data[i].score)/100)+"</span></a><div class='tc_discl'></div><div class='tc_stroke'></div></li>")
                    }
                }else{
                    //$("#Relevantexp").append("<li class='Cell' style='background:#ECECEC'><a class='tc_inner' style='text-align: center'><span class='tc_text' style='font-size:15px;color:#999;'>无相关经验</span></a></li>");
                    $("#moreexp").css("display","none");
                }
            }
        });
        $("#moreexp").css("display","none");
    });

    //去充值
    $("#okgobtn").click(function(){
        location.href="scoredetail.html";
    })
    //不去充值
    $(".cancel3").click(function(){
        $("#waitplace").css("display","none");
        $("body").css("overflow","auto");
    })
    //提交回复评论
    $("#sendcom").click(function(){
        console.log("click");
        var comword=document.getElementById("commentinput").value;
        document.getElementById("commentinput").value="";
        if(comword.replace(/(^\s*)|(\s*$)/g,"")==""){
            console.log("没有内容");
            //$(".RequestAnswersDrawer").attr("class","RequestAnswersDrawer formone isclose");
            //var showheight2=allheihgt;
            //var steps2=0;
            //var timer2=setInterval(function(){
            //    showheight2-=stepleng;
            //    steps2++;
            //    $(".RequestAnswersDrawer").css("height",showheight2+"px");
            //    if(steps2===10){
            //        clearInterval(timer2);
            //    }
            //},20)
        }else{
            console.log("ok");
            var answer={};
            answer.questionId=eid;
            answer.content=comword;
            answer.answerUserId=id;
            answer.atype=3;
            answer.up=0;
            answer.down=0;
            $.ajax({
                type:"post",
                datatype:"json",
                url:"http://42.62.66.198:9001/api/PuluAnswer/AddAnswer",
                data:{"puluanswer":answer,"imgs":""},
                success:function(data){
                    console.log(data.Data);
                    //重新刷新页面
                    //$(".RequestAnswersDrawer").attr("class","RequestAnswersDrawer formone isclose");
                    //var showheight2=allheihgt;
                    //var steps2=0;
                    //var timer2=setInterval(function(){
                    //    showheight2-=stepleng;
                    //    steps2++;
                    //    $(".RequestAnswersDrawer").css("height",showheight2+"px");
                    //    if(steps2===10){
                    //        clearInterval(timer2);
                    //    }
                    //},20)
                    //location.reload();

                    var pinglun="<a class='commentbtn' onclick='comment(this)' data-eid='"+eid+"' id='c"+data.Data+"'>评论</a>";
                    //pinglun="";
                    document.getElementById("commentinput").value='';
                    var newcontentcode=codetoface(comword);//回复文字中插入表情图片
                    if(document.getElementById("QuestionMain").style.display=="none"){
                        document.getElementById("QuestionMain").style.display="block";
                        $(".section_header.section_header_gray").after("<div class='othersanswer'> <div class='AnswerPagedList PagedList'> <div class='Answer on_question_page'> <div class='answer_text'> <div class='ContentHeader'> <div class='photo_info_layout size_small'> <div class='photo_wrapper'> <div class='photo'> <a ><img class='profile_photo_img' src='"+myimg+"'> </a></div> </div> <div class='info_wrapper'> <span class='feed_item_answer_user'> <span class='user'>"+mynick+"</span><span class='sign'>"+mysig+"</span> </span> <div class='ContentFooter'>刚刚</div> </div> </div> </div> <div class='answer_content'> <span class='rendered_qtext'> <p class='qtext_para'>"+newcontentcode+"</p></span> </div> </div><div class='ActionBar'> <div class='action_bar_inner'><div class='action_item'>"+pinglun+"</div></div> </div>     </div> </div> </div>");
                    }
                    else{
                        $(".section_header.section_header_gray").after("<div class='othersanswer'> <div class='AnswerPagedList PagedList'> <div class='Answer on_question_page'> <div class='answer_text'> <div class='ContentHeader'> <div class='photo_info_layout size_small'> <div class='photo_wrapper'> <div class='photo'> <a ><img class='profile_photo_img' src='"+myimg+"'> </a></div> </div> <div class='info_wrapper'> <span class='feed_item_answer_user'> <span class='user'>"+mynick+"</span><span class='sign'>"+mysig+"</span> </span> <div class='ContentFooter'>刚刚</div> </div> </div> </div> <div class='answer_content'> <span class='rendered_qtext'> <p class='qtext_para'>"+newcontentcode+"</p></span> </div> </div><div class='ActionBar'> <div class='action_bar_inner'><div class='action_item'>"+pinglun+"</div></div> </div>     </div> </div> </div>");
                    }
                    history.go(-1);
                    $("#page_wrapper").css("display","block");
                    $("#evaluate").css("display","none");
                }
            })
        }
    });
    //提交并转发----->取消·
    $("#sendcomandother").click(function(){

        document.getElementById("comword").value='';
        $(".RequestAnswersDrawer").attr("class","RequestAnswersDrawer formone isclose");
        var showheight2=allheihgt;
        var steps2=0;
        var timer2=setInterval(function(){
            showheight2-=stepleng;
            steps2++;
            $(".RequestAnswersDrawer").css("height",showheight2+"px");
            if(steps2===10){
                clearInterval(timer2);
            }
        },20)

    });
    //付款
    $("#paymoneybtn").click(function(){
        if($("#moneyinput").val()&&!$("#moneyinput").val().match(/(\s)/)&&$("#moneyinput").val().match(/^[0-9]*$/)){
            $.ajax({
                type:"post",
                datatype:"json",
                url:payexpurl,
                data:{"quserId":euserid,"contentId":eid,"userId":id,"score":$("#moneyinput").val()},
                success:function(d){
                    console.log(d);
                    if(modalbg.style.display=="block"&&modal.style.display=="block"){
                        modalbg.className+=' animate_out';
                        modal.className+=' animate_out';
                    }
                    timer=setTimeout(changeclass,100);
                }
            })
        }
    });
    //收藏
    $("#collectit").click(function(){
        $("#sharewaiting").css("display","block");
        $.ajax({
            type:"post",
            datatype:"json",
            url:"http://42.62.66.198:9001/api/PuluCollection/Addpulu_collection",
            data:{"contentid":eid,"userid":id,"contenttype":3},
            success:function(data){
                $("#sharewaiting").css("display","none");
                $("#collectword a").html("收藏成功");
                $("#collectword").css("display","block");
                setTimeout(function(){
                    $("#collectword").css("display","none");
                },1000);
                clearTimeout();
                //console.log(data);
                if(modalbg1.style.display=="block"&&modal1.style.display=="block"){
                    modalbg1.className+=' animate_out';
                    modal1.className+=' animate_out';
                }
                timer1=setTimeout(changeclass1,100);
            }
        })
    });
    //转发
    var shareword=document.getElementById("shareword");//提示部分
    var cancelbtn=document.getElementById("cancelbtn");//取消按钮
    var commentinput=document.getElementById("commentinput");//评论输入框
    var sendcommentbtn=document.getElementById("sendcommentbtn");//确定按钮
    $("#sharebtn").click(function(){
        $.cookie("sharequeid",eid);

        location.href="sendsharepage.html?type=3";
        if(modalbg1.style.display=="block"&&modal1.style.display=="block"){
            modalbg1.className+=' animate_out';
            modal1.className+=' animate_out';
        }
        timer1=setTimeout(changeclass1,100);
        //shareword.style.display="block";
        //cancelbtn.style.display="block";
    });
    //sendcommentbtn.onclick=function(){
    //    $("#sharewaiting").css("display","block");
    //    if(commentinput.value){
    //        if(commentinput.value.match(/^\s+$/g)){
    //            $.ajax({
    //                type:"post",
    //                datatype:"json",
    //                url:addshareurl,
    //                data:{"contentid":eid,"userid":id,"isfrom":"","des":"","contenttype":3},
    //                success:function(data){
    //                    console.log(data);
    //                    $("#collectword a").html("转发成功");
    //                    $("#sharewaiting").css("display","none");
    //                    $("#collectword").css("display","block");
    //                    setTimeout(function(){
    //                        $("#collectword").css("display","none");
    //                    },1000);
    //                    clearTimeout();
    //                    shareword.style.display="none";
    //                }
    //            })
    //        }else{
    //            $.ajax({
    //                type:"post",
    //                datatype:"json",
    //                url:addshareurl,
    //                data:{"contentid":eid,"userid":id,"isfrom":"","des":commentinput.value,"contenttype":3},
    //                success:function(data){
    //                    console.log(data);
    //                    $("#collectword a").html("转发成功");
    //                    $("#sharewaiting").css("display","none");
    //                    $("#collectword").css("display","block");
    //                    setTimeout(function(){
    //                        $("#collectword").css("display","none");
    //                    },1500);
    //                    clearTimeout();
    //                    shareword.style.display="none";
    //                }
    //            })
    //        }
    //    }else{
    //        $.ajax({
    //            type:"post",
    //            datatype:"json",
    //            url:addshareurl,
    //            data:{"contentid":eid,"userid":id,"isfrom":"","des":"","contenttype":3},
    //            success:function(data){
    //                console.log(data);
    //                $("#collectword a").html("转发成功");
    //                $("#sharewaiting").css("display","none");
    //                $("#collectword").css("display","block");
    //                setTimeout(function(){
    //                    $("#collectword").css("display","none");
    //                },1500);
    //                clearTimeout();
    //                shareword.style.display="none";
    //            }
    //        })
    //    }
    //};
    //取消
    cancelbtn.onclick=function(){
        commentinput.value="";
        shareword.style.display="none";
        cancelbtn.style.display="none";
    }
});
//键盘事件 搜索-------------------------------------------------------
//document.onkeydown=function(event){
//    var e = event || window.event || arguments.callee.caller.arguments[0];
//    if(e && e.keyCode==13){ // enter 键
//        var word=document.getElementById("searchinput").value;
//        if(word){
//            if(word.match(/^\s+$/g)){
//                console.log("没有填信息")
//            }else{
//                location.href="search.html?searchKey="+word;
//            }
//        }
//    }
//};
$("#searchinput").click(function(){
    location.href="search.html?searchKey=";
});
$(".mweb_lookup_bar_input_wrapper.mweb_lookup_bar_input_wrapper_fake.mweb_lookup_bar_input").click(function(){
    location.href="search.html?searchKey=";
});
//输入框点击动画
//findhelp.onclick=function(){
//    if(/isclose/.test($(".RequestAnswersDrawer").attr("class"))){
//        $(".RequestAnswersDrawer").attr("class","RequestAnswersDrawer formone isopen");
//        var showheight1=0;
//        var steps1=0;
//        var timer1=setInterval(function(){
//            showheight1+=stepleng;
//            steps1++;
//            $(".RequestAnswersDrawer").css("height",showheight1+"px");
//            if(steps1===10){
//                clearInterval(timer1);
//            }
//        },20)
//    }else if(/isopen/.test($(".RequestAnswersDrawer").attr("class"))){
//        $(".RequestAnswersDrawer").attr("class","RequestAnswersDrawer formone isclose");
//        var showheight2=allheihgt;
//        var steps2=0;
//        var timer2=setInterval(function(){
//            showheight2-=stepleng;
//            steps2++;
//            $(".RequestAnswersDrawer").css("height",showheight2+"px");
//            if(steps2===10){
//                clearInterval(timer2);
//            }
//        },20)
//    }
//}
//展开表情区域

//$("#facebtn").click(function(){
//    if(/noclick/.test($("#facebtn").attr("class"))){
//        allheihgt=428;
//        stepleng=allheihgt/10;
//        $("#facebtn").attr("class","isclick");
//        $(".RequestAnswersDrawer").css("height",allheihgt+"px");
//        $("#facelist").css("display","block");
//    }
//    else if(/isclick/.test($("#facebtn").attr("class"))){
//        allheihgt=230;
//        stepleng=allheihgt/10;
//        $("#facebtn").attr("class","noclick");
//        $(".RequestAnswersDrawer").css("height",allheihgt+"px");
//        $("#facelist").css("display","none");
//    }
//});
//插入表情字符

//评价操作
$("#findhelp").click(function(){
    location.href+="#evaluate";
    $("#page_wrapper").css("display","none");
    $("#evaluate").css("display","block");
});
$("#closeevaluate").click(function(){
    history.go(-1);
    $("#page_wrapper").css("display","block");
    $("#evaluate").css("display","none");
});
$('#commentinput').bind('input propertychange', function(a) {
    //console.log(a.target);
    var a= a.target;
    //自适应高度
    console.log(a.rows);
    //if(!row){row=1;};
    //var wid=document.getElementById("commentinput").style.width;
    //a.cols=parseInt((wid-10)/15);
    if(a.cols==0){a.cols=20}
    var col=a.cols;
    var val=a.value.length;
    var rownum=1;
    console.log("col",col);
    console.log("val.length",val);
    if(val>=col){
        rownum=Math.ceil(val/col);
        console.log("rownum",rownum);
        if(rownum>=3){
            a.style.overflowY="auto";
            a.rows=3;
        }else{
            a.rows=rownum;
        }
    }
});
//点击评分
var starscore=0;
$("#choicestar>div").click(function(e){
    console.log(e.target.className);
    var showwidth=e.target.className.match(/\d+/)[0];
    $("#choicestar>i").css("width",showwidth+"%");
    starscore=parseInt(showwidth)/20;
    if(starscore>3){
        $("#goodword").css("display","block");
        $("#badword").css("display","none");
    }else if(starscore<=3){
        $("#goodword").css("display","none");
        $("#badword").css("display","block");
    }
});
//$("#choicestar>div").hover(function(e){
//    console.log(e.target.className.match(/\d+/)[0]);
//    var showwidth=e.target.className.match(/\d+/)[0];
//    $("#choicestar>i").css("width",showwidth+"%");
//});
//$("#choicestar").blur(function(e){
//
//    $("#choicestar>i").css("width","0%");
//});
//手机返回
//选取评价操作
$("#evaluate>.choiceword>div").click(function(e){
    if(e.target.className==="chicked"){
        e.target.className="";
    }else{
        e.target.className="chicked";
    }
});
if( ("onhashchange" in window) && ((typeof document.documentMode==="undefined") || document.documentMode==8)) {
//浏览器支持onhashchange事件
    window.onhashchange = hashChangeFire;
    //对应新的hash执行的操作函数
} else { // 不支持则用定时器检测的办法
    setInterval(function() {
        var ischanged = isHashChanged(); //检测hash值或其中某一段是否更改的函数
        if(ischanged) {
            hashChangeFire(); //对应新的hash执行的操作函数
        }
    }, 150);
}
function hashChangeFire(){
    if(!/evaluate/.test(location.href)){
        //将好友列表关闭展示原页面
        $("#page_wrapper").css("display","block");
        $("#evaluate").css("display","none");
    }
}
//---------------------------------------------
function sendface(e){
    var face=e.dataset.key;
    document.getElementById("comword").value+=" "+face;
}
function sendface2(e){
    var face=e.dataset.key;
    document.getElementById("commentinput").value+=face;
}
//转发点开表情操作
var mySwiper2;
$("#facebtn2").click(function(){
    if($("#facelist2").css("display")==="block"){
        $("#facelist2").css("display","none");
    }else{
        $("#facelist2").css("display","block");
        if(!mySwiper2){
            mySwiper2 = new Swiper ('#facelist2 .swiper-container', {
                paginationClickable: true,
                touchRatio : 1,
                initialSlide :0,
                pagination: '#facelist2 .swiper-pagination'
            })
        }

    }
})